<?php
//khoi dong su kien
session_start();
//kiem tra quyen admin
include("kiemtraquyen.php");
//kết nối với csdl
include("connect.php");
?>
<html>
<head>
	<title>Thống Kê</title>
	<link rel="stylesheet" href="quanly.css" type="text/css">
</head>
<body>
	<div align="center">
		<h1>Thống Kê</h1>
		<a href='admin.php'><h4>Quay trở lại trang quản lý</h4></a>
		<table align="center" cellspacing="1px" border="1px" >
		<tr>
			<td align='center' width='5%'>STT</td>
			<td align='center' width='15%'>Môn</td>
			<td align='center' width='15%'>Số Câu Hỏi</td>
			<td align='center' width='15%'>Số Bài Kiểm TRa</td>
			<td align='center'width='15%'>Xem Thống Kê Các Bài Kiểm Tra Trong Môn</td>	
		</tr>
		<?php
			
			//cau lenh sql lay cau hoi tu csdl
			$sqlcauhoi="select * from mon";
			$querycauhoi=mysql_query($sqlcauhoi);
			{
				$stt=0;
				while($row=mysql_fetch_array($querycauhoi))
				{
					$stt++;
					echo"<tr>";
						echo"<td align='center' width='5%'>".$stt."</td>";
						echo"<td align='center'>".$row["TEN_MON"]."</td>";
						$sql1="select count(id) as tongcau from cau_hoi where ma_mon=".$row["MA_MON"].";";
						$query1=mysql_query($sql1);
						$row1=mysql_fetch_array($query1);
						echo"<td width='15%' align='center'>".$row1["tongcau"]."</td>";
						$sql2="select count(ma_kt) as tong from kiemtra where ma_mon=".$row["MA_MON"].";";
						$query2=mysql_query($sql2);
						$row2=mysql_fetch_array($query2);
						echo"<td width='15%' align='center'>".$row2["tong"]."</td>";
						echo"<td align='center'><a href='thongkekt.php?id=".$row["MA_MON"]."' width='15%'>Xem</a></td>";
					echo"</tr>";
				}
			}
		?>

	</div>
</body>
</html>